<template>
  <div>
    <van-nav-bar title="公告" left-text="返回" left-arrow @click-left="back" />
    <van-button @click="message" type="default">声明1</van-button>
    <van-button @click="get" type="default">声明2</van-button>
    <van-button @click="duty" type="default">声明3</van-button>
  
    <van-search style="margin:20px 0" v-model="value" show-action label="标题" placeholder="请输入搜索关键词"
  @search="onSearch">
  <template #action>
    <div @click="onSearch">搜索</div>
  </template>
</van-search>

  <div v-for="item in list" :key="item.id">
    <van-button @click="content(item)" type="default" style="margin-bottom:20px;width:100% ">标题：{{item.title}}</van-button>
  </div>

  </div>
</template>

<script>
import mixin from  "@/mixin/flag";
import {noticestatement,noticelist,noticedetail} from "./Service"
export default {
  mixins:[mixin],
  data(){
    return{
      value:'',
      list:[]
    }
  },
  
  methods:{
    back(){
      this.$router.go(-1);
    },
    async message(){
      let res = await noticestatement({
        type:1
      })
      // console.log(res);
      this.$dialog.alert({
        title: res.data.data.title,
        message: res.data.data.content,
      }).then(() => {
      // on close
      });
    },
    async get(){
      let res = await noticestatement({
        type:2
      })
      // console.log(res);
      this.$dialog.alert({
        title: res.data.data.title,
        message: res.data.data.content,
      }).then(() => {
      // on close
      });
    },
    async duty(){
      let res = await noticestatement({
        type:3
      })
      // console.log(res);
      this.$dialog.alert({
        title: res.data.data.title,
        message: res.data.data.content,
      }).then(() => {
      // on close
      });
    },
    async onSearch(){
      let res = await noticelist({
        title:this.value
      })
      console.log(res);
      this.list=res.data.rows
    },
    async content(item){
      let res = await noticedetail({
        id:item.id
      })
      // console.log(res);
      this.$dialog.alert({
      message: res.data.data.content,
      }).then(() => {
       // on close
       });
    }
  }
}
</script>

<style lang="scss" scoped>
.van-button--default{
  width: calc(100% / 3);
}
.van-dialog__message{
  p{
    text-indent: 1em;
  text-align: left;

  }
  
}

</style>